package com.sciener.service;

import java.util.List;

import com.sciener.dao.MessageDaoImp;
import com.sciener.entity.Message;

public class MessageService {
	MessageDaoImp serviceDao = new MessageDaoImp();
	
	public void inserteMessage(Message message)
	{
		serviceDao.inserteMessage(message);
	}
	
	public void deleteMessageById(int id)
	{
		serviceDao.deleteMessageById(id);
	}
		
	public List<Message> getMessagesByTopicId(int id)
	{
		return serviceDao.getMessagesByTopicId(id);
	}
	
	public void updateMessage(Message message)
	{
		serviceDao.updateMessage(message);
	}
	
	public static void main(String[] args) {
		MessageService s = new MessageService();
		Message message = new Message();
		message.setTopicid(2);
		message.setContent("i am youzi");
		s.inserteMessage(message);
		
		List<Message> l = s.getMessagesByTopicId(1);
		/*for(Message message1 : l)
		{
			message1.setState(1);
			s.updateMessage(message1);
			if(message1.getContent().equals("i am youzi"))
			{
				
			}
		}*/
		s.deleteMessageById(2);
		
		
		
		
	}
}
